package com.yly.test1

import android.content.Context
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import androidx.appcompat.app.AppCompatActivity

class LoginActivity : AppCompatActivity() {
    private lateinit var userStudentNo: EditText
    private lateinit var userPassword: EditText
    private lateinit var loginBtn: Button


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val shp = getSharedPreferences("user", Context.MODE_PRIVATE)

        setContentView(R.layout.activity_main)
        userStudentNo = findViewById(R.id.user_student_no)
        userPassword = findViewById(R.id.user_password)
        loginBtn = findViewById(R.id.login)

        loginBtn.setOnClickListener {
            val userStudentNo = userStudentNo.text.toString()
            val userPassword = userPassword.text.toString()
            val connectThread = Thread {
                connectCampusNetwork(
                    shp.getString("userIndex", null),
                    shp,
                    shp.getString("", null),
                    this@LoginActivity.applicationContext,
                    userStudentNo,
                    userPassword
                )
            }
            connectThread.start()
            Thread.currentThread().join(1000)
        }
    }
}